﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI.WebControls;
using Pampa.WebControls;

namespace Pampa.MVC.Fluent.CustomControls
{
    public class StaticDropDownBuilder : IHtmlString
    {
        private readonly ComboList _comboList;

        public StaticDropDownBuilder(string id)
        {
            _comboList = new ComboList();
            _comboList.ID = id;
            _comboList.CssClass = "comboList";
        }

        public StaticDropDownBuilder Width(int pixels)
        {
            _comboList.Width = pixels;
            return this;
        }

        public StaticDropDownBuilder EmptyText(string text)
        {
            _comboList.EmptyText = text;
            return this;
        }

        public StaticDropDownBuilder Add(string text, string value)
        {
            _comboList.Items.Add(new ListItem(text, value));
            return this;
        }

        public StaticDropDownBuilder OnClientChange(string function)
        {
            _comboList.OnClientChange = function;
            return this;
        }

        public string ToHtmlString()
        {
            var sb = new StringBuilder();
            sb.Append(_comboList.Render());

            return sb.ToString();
        }
    }
}
